package org.ehe.area.service.impl;

import jakarta.annotation.Resource;
import org.ehe.area.domain.City;
import org.ehe.area.domain.Province;
import org.ehe.area.domain.Town;
import org.ehe.area.mapper.CityMapper;
import org.ehe.area.mapper.ProvinceMapper;
import org.ehe.area.mapper.TownMapper;
import org.ehe.area.service.AddressService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author :zhangnn
 * @className :AddressServiceImpl
 * @description: TODO
 * @date 2025-07-29 10:22:00
 */
@Service
public class AddressServiceImpl implements AddressService {

    @Resource
    private ProvinceMapper provinceMapper;

    @Resource
    private CityMapper cityMapper;

    @Resource
    private TownMapper townMapper;

    @Override
    public List<Province> getAllProvinces() {
        // 查询所有省份
        return provinceMapper.selectList(null);
    }

    @Override
    public List<City> getCitiesByProvinceCode(String provinceCode) {
        // 根据省份编码查询城市
        return cityMapper.selectByProvinceCode(provinceCode);
    }

    @Override
    public List<Town> getTownsByCityCode(String cityCode) {
        // 根据城市编码查询区县
        return townMapper.selectByCityCode(cityCode);
    }
}
